data("instacart")
instacart = instacart %>%
select(reordered,add_to_cart_order,order_hour_of_day,days_since_prior_order,product_name,order_dow,aisle,department) %>%
mutate(
order_hour_of_day = as.factor(order_hour_of_day),
order_dow =
as.factor(recode(order_dow,'0' = "Sun",'1' = "Mon",'2' = "Tue",'3' = "Wed",'4' = "Thu",'5' = "Fri",'6' = "Sat")))
Column
Line graph
instacart %>%
group_by(order_dow) %>%
count(order_hour_of_day) %>%
mutate(
text_label = str_c("Time:",order_hour_of_day,"hr","\nOrders:#",n),
order_dow = fct_relevel(order_dow,c("Sun","Mon","Tue","Wed","Thu","Fri","Sat"))) %>%
plot_ly(
x = ~order_hour_of_day, y = ~n, type = "scatter", color = ~order_dow, mode = "lines",text = ~text_label,alpha = 0.5)
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
Column
Boxplot
instacart %>%
filter(reordered == '1',
department != "missing") %>%
mutate(department = reorder(department,days_since_prior_order)) %>%
plot_ly(
x = ~department, y = ~days_since_prior_order, type = "box", color = "viridis", alpha = 0.5)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels